import uniqueId from '@form-create/utils/lib/unique';
import { localeProps, makeRequiredRule } from '../../utils';

const label = '超链接';
const name = 'jd-link';

export default {
    icon: 'icon-pagelink',
    label,
    name,
    rule({ t }) {
        return {
            type: 'jd-link',
            title: '',
            info: '',
            $required: false,
            props: {
                title: '跳转',
                to: '',
                size: 'default',
                type: 'default',
                justify: 'center'
            }
        };
    },
    props(_, { t }) {
        return localeProps(t, name + '.props', [
            {
                type: 'select',
                field: 'type',
                title: '显示类型',
                options: [
                    { label: 'default', value: 'default' },
                    { label: 'primary', value: 'primary' },
                    { label: 'success', value: 'success' },
                    { label: 'warning', value: 'warning' },
                    { label: 'danger', value: 'danger' },
                    { label: 'info', value: 'info' },
                    { label: 'text', value: 'text' }
                ]
            },
            {
                type: 'select',
                field: 'size',
                title: '组件大小',
                options: [
                    { label: 'default', value: 'default' },
                    { label: 'large', value: 'large' },
                    { label: 'small', value: 'small' }
                ]
            },
            {
                type: 'input',
                field: 'title',
                title: '链接名称',
                props: {
                    clearable: true,
                    placeholder: '请输入链接名称'
                }
            },
            {
                type: 'input',
                field: 'to',
                title: '链接地址',
                props: {
                    clearable: true,
                    placeholder: '请输入跳转的地址'
                }
            },
            {
                type: 'radio',
                field: 'justify',
                title: '显示位置',
                options: [
                    { label: '居左', value: 'start' },
                    { label: '居中', value: 'center' },
                    { label: '居右', value: 'end' }
                ]
            },
            {
                type: 'input',
                field: 'customStyle',
                title: '自定义css',
                props: {
                    type: 'textarea',
                    showWordLimit: true,
                    rows: 5,
                    placeholder: `请按照css语法书写( 属性名:属性值; ),例: padding: 0; color: #000;`
                }
            }
        ]);
    }
};
